﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Controls;
using MediaPad.Implementation.Enums;

namespace MediaPad.Resources
{
    public class InkCanvasMediaModeToBool : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            InkCanvasAdvMediaMode mode = (InkCanvasAdvMediaMode)value;

            switch (parameter.ToString())
            {
                case "Text":

                    return mode == InkCanvasAdvMediaMode.Text;

                case "Image":

                    return mode == InkCanvasAdvMediaMode.Image;

                case "Video":

                    return mode == InkCanvasAdvMediaMode.Video;

                default:

                    return mode == InkCanvasAdvMediaMode.None;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            bool hasValue = (bool)value;
            if (hasValue)
            {
                switch (parameter.ToString())
                {
                    case "Text":

                        return InkCanvasAdvMediaMode.Text;

                    case "Image":

                        return InkCanvasAdvMediaMode.Image;

                    case "Video":

                        return InkCanvasAdvMediaMode.Video;

                    default:

                        return InkCanvasAdvMediaMode.None;
                }
            }

            return InkCanvasAdvMediaMode.None;
        }

        #endregion
    }
}
